package com.st.shopadmin.controller;

import com.st.shopadmin.annotation.LoginAccess;
import com.st.shopadmin.common.ServerResponse;
import com.st.shopadmin.pojo.BuyerUserInfo;
import com.st.shopadmin.pojo.TaskInfo;
import com.st.shopadmin.service.TaskService;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/manage/task/")
public class TaskManagerController {
    @Autowired
    private TaskService taskService;

    @RequestMapping("/to_list.do")
    public String task()  {
        return "task/list";
    }

    /**
     * class_name: TaskManagerController
     * package: com.st.shopadmin.controller
     * describe: 任务列表（前端分页）
     * author: duhongpeng
     * date: 2018/10/31
     * time: 8:46
     **/
    @RequestMapping("lists.do")
    @ResponseBody
    @LoginAccess
    public ServerResponse getTaskLists(HttpServletRequest httpServletRequest, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum,@RequestParam(value = "pageSize",defaultValue = "10") int pageSize){
        ServerResponse<List> serverResponse = taskService.getTaskLists(pageNum,pageSize);
        serverResponse.setTotal(serverResponse.getData().size());
        return serverResponse;
    }

    /**
     * class_name: TaskManagerController
     * package: com.st.shopadmin.controller
     * describe: 任务列表（后端分页）
     * author: duhongpeng
     * date: 2018/10/31
     * time: 8:46
     **/
    @RequestMapping("taskPage.do")
    @ResponseBody
    @LoginAccess
    public ServerResponse taskPage(HttpServletRequest httpServletRequest, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum,@RequestParam(value = "pageSize",defaultValue = "10") int pageSize){
        return  taskService.taskPage(pageNum,pageSize);
    }

    /**
     * class_name: TaskManagerController
     * package: com.st.shopadmin.controller
     * describe: 任务详情
     * author: duhongpeng
     * date: 2018/10/31
     * time: 8:46
     **/
    @RequestMapping("task_detail.do")
    @ResponseBody
    @LoginAccess
    public ServerResponse taskDetail(HttpServletRequest httpServletRequest, Long taskId){
        return taskService.taskDetail(taskId);
    }


    /**
     * class_name: TaskManagerController
     * package: com.st.shopadmin.controller
     * describe: 任务关键字
     * author: duhongpeng
     * date: 2018/10/31
     * time: 8:46
     **/
    @RequestMapping("task_keywords.do")
    @ResponseBody
    @LoginAccess
    public ServerResponse taskKeywords(HttpServletRequest httpServletRequest, Long taskId){
        return taskService.taskKeywords(taskId);
    }

    /**
     * class_name: TaskManagerController
     * package: com.st.shopadmin.controller
     * describe: 任务审核
     * author: duhongpeng
     * date: 2018/10/31
     * time: 8:46
     **/
    @RequestMapping("check_task.do")
    @ResponseBody
    @LoginAccess
    public ServerResponse checkTask(HttpServletRequest httpServletRequest, Long taskId,Integer status,String noPassReason){
        return taskService.checkTask(taskId,status,noPassReason);
    }
    /**
     * class_name: TaskManagerController
     * package: com.st.shopadmin.controller
     * describe: 搜索
     * author: duhongpeng
     * date: 2018/10/31
     * time: 8:46
     **/
    @RequestMapping("searchLists.do")
    @ResponseBody
    public ServerResponse searchLists(HttpServletRequest httpServletRequest, TaskInfo taskInfo,@RequestParam(value = "pageNum",defaultValue = "1") int pageNum,@RequestParam(value = "pageSize",defaultValue = "10") int pageSize){
        ServerResponse<List> serverResponse = taskService.searchLists(taskInfo,pageNum,pageSize);
        serverResponse.setTotal(serverResponse.getData().size());
        return serverResponse;
    }



}
